package launcher;

import java.io.File;
import java.io.ObjectInputStream.GetField;
import java.util.Scanner;
import java.util.Vector;

import metrics.NormalizedPRStatictic;
import metrics.PrRcGraph;

import org.jfree.ui.RefineryUtilities;

import query.VectorQueryLibrary;
import document.DocumentLibrary;
import document.InvertedIndex;
import document.Stemmer;
import document.StopWordLexicon;

public class ShowGraph {

	private static final String DOC_PATH =  "TIME" + File.separator + "Docs";
	private static final String QUERY_PATH =  "TIME" + File.separator + "IR_2nd_Project_Queries";
	
	public static void main(String[] args) 
	{

		Vector<NormalizedPRStatictic> entries = new Vector<NormalizedPRStatictic>();
		NormalizedPRStatictic withAll = getStatistics(false, false);
		withAll.setLabel("With Stopwords and Stemming");
		entries.add(withAll);
		
		NormalizedPRStatictic withStem = getStatistics(true, false);
		withStem.setLabel("With Stemming");
		entries.add(withStem);
		
		NormalizedPRStatictic withStop = getStatistics(false, true);
		withStop.setLabel("With Stopwords");
		entries.add(withStop);
		
		NormalizedPRStatictic withNone = getStatistics(true, true);
		withNone.setLabel("Without all");
		entries.add(withNone);
		
		PrRcGraph graph = new PrRcGraph(entries);
                graph.pack();
                RefineryUtilities.centerFrameOnScreen(graph);
                graph.setVisible(true);



	}
	
	private static NormalizedPRStatictic getStatistics(boolean noStopWords, boolean noStemming) {
		StopWordLexicon.setDisabled(noStopWords);
		Stemmer.setDisabled(noStemming);
		DocumentLibrary library = new DocumentLibrary();
		library.initializeFrom(DOC_PATH);
		InvertedIndex index = new InvertedIndex();
		index.indexLibrary(library);
		
		VectorQueryLibrary lib = new VectorQueryLibrary();
		lib.initializeFrom(QUERY_PATH);
		
	
		lib.processAll(index);
		return lib.getStatistics();
	}

}
